package com.ruoyi.system.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TicketOrderMapper;
import com.ruoyi.system.domain.TicketOrder;
import com.ruoyi.system.service.ITicketOrderService;
import com.ruoyi.common.core.text.Convert;

/**
 * 订票订单信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-01-10
 */
@Service
public class TicketOrderServiceImpl implements ITicketOrderService 
{
    @Autowired
    private TicketOrderMapper ticketOrderMapper;

    /**
     * 查询订票订单信息
     * 
     * @param id 订票订单信息主键
     * @return 订票订单信息
     */
    @Override
    public TicketOrder selectTicketOrderById(Long id)
    {
        return ticketOrderMapper.selectTicketOrderById(id);
    }

    /**
     * 查询订票订单信息列表
     * 
     * @param ticketOrder 订票订单信息
     * @return 订票订单信息
     */
    @Override
    public List<TicketOrder> selectTicketOrderList(TicketOrder ticketOrder)
    {
        return ticketOrderMapper.selectTicketOrderList(ticketOrder);
    }

    /**
     * 新增订票订单信息
     * 
     * @param ticketOrder 订票订单信息
     * @return 结果
     */
    @Override
    public int insertTicketOrder(TicketOrder ticketOrder)
    {
        return ticketOrderMapper.insertTicketOrder(ticketOrder);
    }

    /**
     * 修改订票订单信息
     * 
     * @param ticketOrder 订票订单信息
     * @return 结果
     */
    @Override
    public int updateTicketOrder(TicketOrder ticketOrder)
    {
        return ticketOrderMapper.updateTicketOrder(ticketOrder);
    }

    /**
     * 批量删除订票订单信息
     * 
     * @param ids 需要删除的订票订单信息主键
     * @return 结果
     */
    @Override
    public int deleteTicketOrderByIds(String ids)
    {
        return ticketOrderMapper.deleteTicketOrderByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除订票订单信息信息
     * 
     * @param id 订票订单信息主键
     * @return 结果
     */
    @Override
    public int deleteTicketOrderById(Long id)
    {
        return ticketOrderMapper.deleteTicketOrderById(id);
    }

    /**
     * selectTicketOrderSeatList 查询某个场次的所有座位，参数 long showTimeId，结果List<String> -->
     */
    @Override
    public ArrayList<String> selectTicketOrderSeatList(Long showTimeId)
    {
        ArrayList<String> list = this.ticketOrderMapper.selectTicketOrderSeatList(showTimeId);
        System.out.println("查询字符串结果="+list);
        ArrayList<String> result = new ArrayList<>();
        for(String temp : list)
        {
            result.addAll(StringUtils.str2List(temp, ",", true, true));
        }
        System.out.println("处理结果。查询字符串结果="+result);
        return result;
    }
}
